import App from './App'
import * as Pinia from 'pinia';
const pinia = Pinia.createPinia()
import 'uno.css'
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)

	pinia.use(({store})=>{			//store.$reset()受语法糖影响 故加此代码
	  const initialState = JSON.parse(JSON.stringify(store.$state));
	  store.$reset = () => {
			store.$patch(initialState)
	  }
	})

	app.use(pinia);
	//简单跳转
	app.config.globalProperties.go = (router,args) => {

		let url = `/pages/${router}/index`
		if(['index','store','demand','enterprise','my'].includes(router)) {
			uni.switchTab({ url })
			return
		}

		if(args) {
			url += `?${args}`
		}
		uni.navigateTo({ url })
	}

	//返回上一页
	app.config.globalProperties.back = () => {
		uni.navigateBack()
	}
	
	return {
    app,
		Pinia
  }
}
// #endif
